package com.neuedu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.entity.Room;
import com.neuedu.mapper.RoomMapper;
import com.neuedu.service.RoomService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 房间表 服务实现类
 * </p>
 *
 * @author wangyu
 * @since 2025-10-14
 */
@Service
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room> implements RoomService {
    @Resource(name = "myredistemplate")
    RedisTemplate<String, Object> redisTemplate;
    @Override
    public IPage<Room> list(Integer pageNo, Integer pageSize, String roomNo) {
        QueryWrapper<Room> wrapper = new QueryWrapper<>();
        if (StringUtils.isNoneBlank(roomNo)) {
            wrapper.like("room_no", roomNo);
        }
        wrapper.orderByDesc("id");
        return this.page(new Page<>(pageNo, pageSize), wrapper);
    }

    @Override
    public List<Room> getForOptions(Integer bedId) {
        return this.baseMapper.getForOptions(bedId);
    }

}
